<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\DB;

class PhotoController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {    	
        echo URL::current();
        echo '<br/>';
        
    	$title = '<span style="color: red">照片</span>名称1';
    	$intro = '文章一的简介';
    	//1.使用with()方法
    	//return view('photo.index')->with('title',$title);
    	//2.直接给view()传参数     	
    	//return view('photo.index',['title'=>$title,'introduction'=>$intro]);
    	//3.使用compact     	
    	return view('photo.index',compact('title','intro'));
    	//-----------------------------------------------------------------------------------
//     	$users = DB::select('select * from my_users where active = ?', [1]);    	
//     	foreach ($users as $user) {
//     		echo $user->user_name;
//     	}
       //------------------------------------------------------------------------------------
    	//使用命名绑定
//     	$results = DB::select('select * from my_users where user_id = :user_id', ['user_id' => 3]);
    	//------------------------------------------------------------------------------------
    	//运行插入语句
//     	$results = DB::insert('insert into my_users (user_name, create_at,update_at) values (?,?,?)', ['赵茜', time(),time()]);
    	//运行更新语句
//     	$affected = DB::update('update my_users set active = 0 where user_name = ?', ['赵茜']);
    	//运行删除语句
//     	DB::beginTransaction();
//     	$deleted = DB::delete('delete from my_users');    	
//     	if($deleted){
//     		DB::commit();
//     	}else{
//     		DB::rollBack();
//     	}
//     	DB::transaction(function () {
//     		DB::table('users')->update(['active' => 1]);    		
//     	},3);
//     	$users = DB::table('users')->simplePaginate(2);
//     	echo '<pre>';
//     	var_export($users);
//     	echo '</pre>';exit();
    	
//     	return view('photo.index', ['users' => $users]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
